package com.xcjh.smartchat.ui.ttt

import android.annotation.SuppressLint
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.window.SplashScreenView
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.xcjh.base_lib.base.activity.BaseActivity
import com.xcjh.smartchat.R
import com.xcjh.smartchat.ui.MainActivity

/**
 * SplashScreen
 */
@SuppressLint("CustomSplashScreen")
class Splash2Activity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        // 处理初始屏幕过渡
        val mSplashScreen = installSplashScreen()
        super.onCreate(savedInstanceState)
        // 保持初始屏幕对此活动可见
        // setContentView(R.layout.chat_activity_splash)
        //一直停留在SplashScreen启动界面
        //splashScreen.setKeepOnScreenCondition { true }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
            splashScreen.setOnExitAnimationListener { splashScreenView: SplashScreenView ->
                splashScreenView.removeAllViews()
                val view: View = LayoutInflater.from(this).inflate(R.layout.chat_activity_splash, null, false)
                splashScreenView.addView(view)
                view.setOnClickListener { v ->
                    startMyActivity<MainActivity> {  }
                }
            }
        }else{
            startMyActivity<MainActivity> {  }
        }

    }
}